import axios from './axios'
import qs from 'qs'

export function getUnitType() {
    return axios.get('/device_type/manage/get_device_type_list.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function addUnitType(typeName,description) {
    return axios.post('/device_type/manage/add_device_type.do',qs.stringify({typeName,description})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))

}

export function modUnitType(unit) {
    return axios.post('/device_type/manage/update_device_type.do',qs.stringify(unit)).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))

}

export function getModelList() {
    return axios.post('/device_field/manage/get_device_field_list.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err))

}

export function giveModel(typeId,fieldId) {
    return axios.post('/device_field/manage/add_type_field.do',qs.stringify({typeId,fieldId})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}
export function getModel(typeId) {
    return axios.post('/device_field/manage/get_type_field_list.do',qs.stringify({typeId})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function addModel(genre,fieldName,fieldCode) {
    return axios.post('/device_field/manage/add_device_field.do',qs.stringify({genre,fieldName,fieldCode})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function getUnitList() {
    return axios.post('/device/manage/get_device_list.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function getUnitDetail(deviceId) {
    return axios.post('/device_detail/manage/get_device_detail.do',qs.stringify({deviceId})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function addUnit(supplierId,models,purchasePrice,type,parameter,configure) {
    return axios.post('/device/manage/add_device_master.do',qs.stringify({supplierId,models,purchasePrice,type,parameter,configure})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}
export function modUnit(id,purchasePrice,parameter,configure) {
    return axios.post('/device/manage/update_device_master.do',qs.stringify({id,purchasePrice,parameter,configure})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err));
}
export function getCataList() {
    return axios.post('/configure_style/manage/get_configure_style_list.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err));
}

export function getUnitOptionList() {
    return axios.post('/configure_price/manage/get_all_configure_price_list.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function getUnitFieldList() {
    return axios.get('/device_field/manage/get_device_field_list_configure.do').then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}

export function getTypeList({fieldId}) {
    return axios.post('/configure_type/manage/get_field_configure_type_list.do',qs.stringify({fieldId})).then(res=>Promise.resolve(res.data),err=>Promise.reject(err))
}
export function modType({id,typeName}) {
    return axios.post('/configure_type/manage/update_configure_type.do',qs.stringify({id,typeName})).then(res=>Promise.resolve(res.data))
}
export function addType({fieldId,typeName}) {
    return axios.post('/configure_type/manage/add_configure_type.do',qs.stringify({fieldId,typeName})).then(res=>Promise.resolve(res.data))
}


export function addPrice({typeId,styleId,purchasePrice,salePrice}) {
    return axios.post('/configure_price/manage/add_configure_price.do',qs.stringify({typeId,styleId,purchasePrice,salePrice})).then(res=>Promise.resolve(res.data))
}

export function modPrice({id,purchasePrice,salePrice}) {
    return axios.post('/configure_price/manage/update_configure_price.do',qs.stringify({id,purchasePrice,salePrice})).then(res=>Promise.resolve(res.data))
}

export function getCapacityList() {
    return axios.post('/configure_style/manage/get_configure_style_list.do').then(res=>Promise.resolve(res.data))
}